home *** CD-ROM | disk | FTP | other *** search
/ PC World 2004 December / PCWorld_2004-12_cd.bin / software / temacd / tiny / tf6pro-6[1].0.140.exe / Tiny Firewall Pro 6.0.msi / log.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-20  |  15.0 KB  |  382 lines

  1. <?xml version='1.0' ?>
  2. <!-- /*//////////////////////////////////////////////////////////////////////
  3. //filename:         log.xsl
  4. //copyright(c):     Tiny Software corp 2002, 2003 (http://www.tinysoftware.com)
  5. //author:         Jozef Palocko (jpalocko@tinysoftware.com)
  6. //product:         Tiny Personal Firewall 5.x                
  7. //description:     Log analyzer stylesheet
  8. //changelog:    
  9. //    18.8.2003 - added displaying date in local time zone
  10. ///////////////////////////////////////////////////////////////////////*/ -->
  11. <xsl:stylesheet version="1.0" 
  12.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  13.     xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  14.     xmlns:time="http://mycompany.com/mynamespace">
  15.  
  16.  
  17. <xsl:output method="html" indent="yes" />
  18. <msxsl:script language="JScript" implements-prefix="time">
  19.   <![CDATA[
  20.      function LocalTime(node)
  21.    {
  22.        nd = node.nextNode();
  23.         t = new Date(Date.parse(nd.getAttribute("dateTimeLast")));
  24.        return t.toLocaleString( );   
  25.    }
  26.    ]]>
  27. </msxsl:script>
  28.     
  29. <xsl:variable name="Def" select="document('../FncIds.xml ')"/>
  30. <xsl:variable name="Filter" select="document('filter.xml')"/>
  31.  
  32.  <!-- 
  33.  //////////////////////////////////////
  34.  ///////// Named filter templates 
  35.  -->
  36.  
  37.    <!-- ///////// tplModule //////////// -->
  38.  
  39.    <xsl:template name="tplModule" >
  40.        <xsl:param name="Events"/>
  41.        <xsl:choose>
  42.             <xsl:when test='$Filter//module="1"'>
  43.                 <xsl:call-template name="tplObject">
  44.                     <xsl:with-param name="Events" select='$Events[@module = "Windows Security" ]'/>
  45.                 </xsl:call-template>
  46.             </xsl:when>
  47.             <xsl:when test='$Filter//module="2"'>
  48.                 <xsl:call-template name="tplDirection">
  49.                     <xsl:with-param name="Events" select='$Events[@module = "Firewall" ]'/>
  50.                 </xsl:call-template>      
  51.             </xsl:when>
  52.             <xsl:when test='$Filter//module="16"'>
  53.                 <xsl:call-template name="tplMessage">
  54.                     <xsl:with-param name="Events" select='$Events[@module = "IDS" ]'/>
  55.                 </xsl:call-template>      
  56.             </xsl:when>
  57.             <xsl:otherwise>
  58.                 <xsl:call-template name="tplAr">
  59.                     <xsl:with-param name="Events"  select="$Events"/>
  60.                 </xsl:call-template>    
  61.             </xsl:otherwise>
  62.         </xsl:choose> 
  63.    </xsl:template>
  64.  
  65.     <!-- ///////// tplObject //////////// -->
  66.  
  67.    <xsl:template name="tplObject" >
  68.        <xsl:param name="Events"/>
  69.        <xsl:choose>
  70.             <xsl:when test="$Filter//string=''">
  71.                 <xsl:call-template name="tplAr">
  72.                     <xsl:with-param name="Events" select="$Events"/>
  73.                 </xsl:call-template>
  74.             </xsl:when>
  75.             <xsl:otherwise>
  76.                 <xsl:call-template name="tplAr">
  77.                     <xsl:with-param name="Events" select="$Events[contains(
  78.                             translate( Object, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'), 
  79.                     translate($Filter//string,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>           
  80.  
  81.                 </xsl:call-template>
  82.             </xsl:otherwise>
  83.         </xsl:choose> 
  84.    </xsl:template>
  85.    
  86.     <!-- ///////// tplMessage //////////// -->
  87.  
  88.    <xsl:template name="tplMessage" >
  89.        <xsl:param name="Events"/>
  90.        <xsl:choose>
  91.             <xsl:when test="$Filter//string=''">
  92.                 <xsl:call-template name="tplAr">
  93.                     <xsl:with-param name="Events" select="$Events"/>
  94.                 </xsl:call-template>
  95.             </xsl:when>
  96.             <xsl:otherwise>
  97.                 <xsl:call-template name="tplAr">
  98.                     <xsl:with-param name="Events" select="$Events[contains(
  99.                             translate( Msg, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'), 
  100.                     translate($Filter//string,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>           
  101.  
  102.                 </xsl:call-template>
  103.             </xsl:otherwise>
  104.         </xsl:choose> 
  105.    </xsl:template>
  106.  
  107.  
  108.  
  109.    <!-- ///////// tplDirection //////////// -->
  110.       <xsl:template name="tplDirection" >
  111.        <xsl:param name="Events"/>
  112.        <xsl:choose>
  113.             <xsl:when test="$Filter//direction=''">
  114.                 <xsl:call-template name="tplProtocol">
  115.                     <xsl:with-param name="Events" select="$Events"/>
  116.                 </xsl:call-template>     
  117.             </xsl:when>
  118.             <xsl:otherwise>
  119.                 <xsl:call-template name="tplProtocol">
  120.                     <xsl:with-param name="Events" select="$Events[InetDef/@dir = $Filter//direction]"/>
  121.                 </xsl:call-template>
  122.             </xsl:otherwise>
  123.         </xsl:choose> 
  124.    </xsl:template>
  125.  
  126.  
  127.    <!-- ///////// tplProtocol //////////// -->
  128.       <xsl:template name="tplProtocol" >
  129.        <xsl:param name="Events"/>
  130.        <xsl:choose>
  131.             <xsl:when test="$Filter//protocol=''">
  132.                 <xsl:call-template name="tplIPAddress">
  133.                     <xsl:with-param name="Events" select="$Events"/>
  134.                 </xsl:call-template>     
  135.             </xsl:when>
  136.             <xsl:otherwise>
  137.                 <xsl:call-template name="tplIPAddress">
  138.                     <xsl:with-param name="Events" select="$Events[contains(InetDef/@prot , $Filter//protocol)]"/>
  139.                 </xsl:call-template>
  140.             </xsl:otherwise>
  141.         </xsl:choose> 
  142.    </xsl:template>
  143.  
  144.  
  145.     <!-- ///////// tplIPAddress //////////// -->
  146.     <xsl:template name="tplIPAddress" >
  147.        <xsl:param name="Events"/>
  148.        <xsl:choose>
  149.             <xsl:when test="$Filter//ip=''">
  150.                 <xsl:call-template name="tplRemPort">
  151.                     <xsl:with-param name="Events" select="$Events"/>
  152.                 </xsl:call-template>     
  153.             </xsl:when>
  154.             <xsl:otherwise>
  155.                 <xsl:call-template name="tplRemPort">
  156.                     <xsl:with-param name="Events" select="$Events[contains(
  157.                             translate( InetDef/@remIp, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'), 
  158.                     translate($Filter//ip,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>  
  159.                 </xsl:call-template>
  160.             </xsl:otherwise>
  161.         </xsl:choose> 
  162.    </xsl:template>
  163.  
  164.    
  165.    <!-- ///////// tplRemPort //////////// -->
  166.  
  167.    <xsl:template name="tplRemPort" >
  168.        <xsl:param name="Events"/>
  169.        <xsl:choose>
  170.             <xsl:when test="$Filter//remport=''">
  171.                 <xsl:call-template name="tplLocPort">
  172.                     <xsl:with-param name="Events" select="$Events"/>
  173.                 </xsl:call-template> 
  174.             </xsl:when>
  175.             <xsl:otherwise>
  176.                 <xsl:call-template name="tplLocPort">
  177.                     <xsl:with-param name="Events" select="$Events[InetDef/@remPort = $Filter//remport]"/>
  178.                 </xsl:call-template> 
  179.             </xsl:otherwise>
  180.         </xsl:choose> 
  181.    </xsl:template>
  182.    
  183.    <!-- ///////// tplLocPort //////////// -->
  184.  
  185.    <xsl:template name="tplLocPort" >
  186.        <xsl:param name="Events"/>
  187.        <xsl:choose>
  188.             <xsl:when test="$Filter//locport=''">
  189.                 <xsl:call-template name="tplAr">
  190.                     <xsl:with-param name="Events"  select="$Events"/>
  191.                 </xsl:call-template>    
  192.             </xsl:when>
  193.             <xsl:otherwise>
  194.                 <xsl:call-template name="tplAr">
  195.                     <xsl:with-param name="Events" select="$Events[InetDef/@locPort = $Filter//locport]"/>
  196.                 </xsl:call-template>    
  197.             </xsl:otherwise>
  198.         </xsl:choose> 
  199.    </xsl:template>
  200.    
  201.     <!-- ///////// tpl access result //////////// -->
  202.    <xsl:template name="tplAr" >
  203.        <xsl:param name="Events"/>
  204.        <xsl:choose>
  205.             <xsl:when test="$Filter//ar=''">
  206.                 <xsl:call-template name="tplApplication">
  207.                     <xsl:with-param name="Events" select="$Events"/>
  208.                 </xsl:call-template>     
  209.             </xsl:when>
  210.             <xsl:otherwise>
  211.                 <xsl:call-template name="tplApplication">
  212.                     <xsl:with-param name="Events"  select="$Events[Action = $Filter//ar]"/>
  213.                 </xsl:call-template>
  214.             </xsl:otherwise>
  215.         </xsl:choose> 
  216.    </xsl:template>
  217.  
  218.     <!-- ///////// tplApplication result //////////// -->
  219.  
  220.    <xsl:template name="tplApplication" >
  221.        <xsl:param name="Events"/>
  222.        <xsl:choose>
  223.             <xsl:when test="$Filter//app=''">
  224.                 <xsl:call-template name="tplUser">
  225.                     <xsl:with-param name="Events" select="$Events"/>
  226.                 </xsl:call-template>
  227.             </xsl:when>
  228.             <xsl:otherwise>
  229.                 <xsl:call-template name="tplUser">
  230.                     <xsl:with-param name="Events" select="$Events[contains(
  231.                             translate( App, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'), 
  232.                     translate($Filter//app,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>
  233.                 </xsl:call-template>
  234.             </xsl:otherwise>
  235.         </xsl:choose> 
  236.    </xsl:template>
  237.  
  238.     <!-- ///////// tplUser result //////////// -->
  239.  
  240.     <xsl:template name="tplUser" >
  241.        <xsl:param name="Events"/>
  242.        <xsl:choose>
  243.             <xsl:when test="$Filter//user=''">
  244. <!-- should never occur -->
  245.                 <xsl:call-template name="tplDomain">
  246.                     <xsl:with-param name="Events" select="$Events"/>
  247.                 </xsl:call-template>
  248.             </xsl:when>
  249.             <xsl:when test="$Filter//user='All Users (*)'">
  250.                 <xsl:choose>
  251.                 <xsl:when test="$Filter//sort='App'">
  252.                     <xsl:apply-templates select='$Events[     not(@module="IDS") and not(App=preceding-sibling::Event/App) or
  253.                                                             not(@module=preceding-sibling::Event/@module) or
  254.                                                             not(count(@user)=0) and not(@user=preceding-sibling::Event/@user) or
  255.                                                             not(count(@domain)=0) and not(@domain=preceding-sibling::Event/@domain) or
  256.                                                             @module="IDS" and not(Msg=preceding-sibling::Event/Msg) or
  257.                                                             not(Action=preceding-sibling::Event/Action) or
  258.                                                             @module="Firewall" and not (
  259.                                                                         InetDef/@prot=preceding-sibling::Event/InetDef/@prot and
  260.                                                                         (count(InetDef/@dir)=0 or InetDef/@dir=preceding-sibling::Event/InetDef/@dir) and
  261.                                                                         (count(InetDef/@remPort)=0 or InetDef/@remPort=preceding-sibling::Event/InetDef/@remPort) and
  262.                                                                         (count(InetDef/@remIp)=0 or InetDef/@remIp=preceding-sibling::Event/InetDef/@remIp)
  263.                                                                            )
  264.                                                         ]'>
  265.                         <xsl:with-param name="Total" select="count($Events)"/>
  266.                         <xsl:with-param name="Events" select="$Events"/>
  267.  
  268.                         <xsl:sort select="App" order="ascending"/>
  269.                         <xsl:sort select="@module" order="ascending"/>
  270.                         <xsl:sort select="@user" order="ascending"/>
  271.                         <xsl:sort select="@domain" order="ascending"/>
  272.                         <xsl:sort select="Object" order="ascending"/>
  273.                         <xsl:sort select="Msg" order="ascending"/>
  274.                         <xsl:sort select="Action" order="ascending"/>
  275.                         <xsl:sort select="InetDef/@dir" order="ascending"/>
  276.                         <xsl:sort select="InetDef/@remIp" order="ascending"/>
  277.                         <xsl:sort select="InetDef/@LocIp" order="ascending"/>
  278.  
  279.                     </xsl:apply-templates>
  280.                 </xsl:when>
  281.                 <xsl:otherwise>
  282.                     <xsl:apply-templates select="$Events">
  283.                         <xsl:with-param name="Total" select="count($Events)"/>
  284.  
  285.                     </xsl:apply-templates>
  286.                 </xsl:otherwise>
  287.                 </xsl:choose>
  288.             </xsl:when>
  289.             <xsl:otherwise>
  290.                 <xsl:call-template name="tplDomain">
  291.                     <xsl:with-param name="Events" select="$Events[@module='IDS' or contains(
  292.                         translate( @user, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'), 
  293.                         translate($Filter//user,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>
  294.                 </xsl:call-template>
  295.             </xsl:otherwise>
  296.         </xsl:choose> 
  297.    </xsl:template>
  298.  
  299.     <!-- ///////// tplDomain result //////////// -->
  300.  
  301.     <xsl:template name="tplDomain" >
  302.        <xsl:param name="Events"/>
  303.     <xsl:variable name="EventsSortedByApp" select="$Events[     not(@module='IDS') and not(App=preceding-sibling::Event/App) or
  304.                                                             not(@module=preceding-sibling::Event/@module) or
  305.                                                             not(count(@domain)=0) and not(@domain=preceding-sibling::Event/@domain) or
  306.                                                             @module='IDS' and not(Msg=preceding-sibling::Event/Msg) or
  307.                                                             not(Action/@ar=preceding-sibling::Event/Action/@ar) or
  308.                                                             @module='Firewall' and not (
  309.                                                                         InetDef/@prot=preceding-sibling::Event/InetDef/@prot and
  310.                                                                         (count(InetDef/@dir)=0 or InetDef/@dir=preceding-sibling::Event/InetDef/@dir) and
  311.                                                                         (count(InetDef/@remPort)=0 or InetDef/@remPort=preceding-sibling::Event/InetDef/@remPort) and
  312.                                                                         (count(InetDef/@remIp)=0 or InetDef/@remIp=preceding-sibling::Event/InetDef/@remIp)
  313.                                                                            )
  314.                                                         ]"/>
  315.        <xsl:choose>
  316.             <xsl:when test="$Filter//domain=''">
  317. <!-- domain filter is empty -->
  318.                 <xsl:choose>
  319.                 <xsl:when test="$Filter//sort='App'">
  320.                     <xsl:apply-templates select="$EventsSortedByApp">
  321.                         <xsl:with-param name="Total" select="count($Events)"/>
  322.  
  323.                         <xsl:sort select="App" order="ascending"/>
  324.                         <xsl:sort select="@domain" order="ascending"/>
  325.                         <xsl:sort select="@module" order="ascending"/>
  326.                         <xsl:sort select="Object" order="ascending"/>
  327.                         <xsl:sort select="Msg" order="ascending"/>
  328.                         <xsl:sort select="Action" order="ascending"/>
  329.                         <xsl:sort select="InetDef/@dir" order="ascending"/>
  330.                         <xsl:sort select="InetDef/@remIp" order="ascending"/>
  331.                         <xsl:sort select="InetDef/@LocIp" order="ascending"/>
  332.  
  333.                     </xsl:apply-templates>
  334.                 </xsl:when>
  335.                 <xsl:otherwise>
  336.                     <xsl:apply-templates select="$Events">
  337.                         <xsl:with-param name="Total" select="count($Events)"/>
  338.                     </xsl:apply-templates>                    
  339.                 </xsl:otherwise>
  340.                 </xsl:choose>
  341.             </xsl:when>
  342.             <xsl:otherwise>
  343. <!-- domain filter is not empty -->
  344.                 <xsl:choose>
  345.                     <xsl:when test="$Filter//sort='App'">
  346.                         <xsl:variable name="selected_events" select="$EventsSortedByApp[contains(
  347.                             translate( @domain, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'), 
  348.                             translate($Filter//domain,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>
  349.                         <xsl:apply-templates select="$selected_events">
  350.                             <xsl:with-param name="Total" select="count($selected_events)"/>
  351. <!-- count all events from this user and domain, not sorted by app -->
  352.                             <xsl:with-param name="Events" select="$Events[contains(
  353.                             translate( @domain, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'), 
  354.                             translate($Filter//domain,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>
  355.                         <xsl:sort select="App" order="ascending"/>
  356.                         <xsl:sort select="@domain" order="ascending"/>
  357.                         <xsl:sort select="@module" order="ascending"/>
  358.                         <xsl:sort select="Object" order="ascending"/>
  359.                         <xsl:sort select="Msg" order="ascending"/>
  360.                         <xsl:sort select="Action" order="ascending"/>
  361.                         <xsl:sort select="InetDef/@dir" order="ascending"/>
  362.                         <xsl:sort select="InetDef/@remIp" order="ascending"/>
  363.                         <xsl:sort select="InetDef/@LocIp" order="ascending"/>
  364.  
  365.                         </xsl:apply-templates>
  366.                     </xsl:when>
  367.                     <xsl:otherwise>
  368.                             <xsl:variable name="selected_events" select="$Events[   @module='IDS' or contains(
  369.                             translate( @domain, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'), 
  370.                                 translate($Filter//domain,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>
  371.                             <xsl:apply-templates select="$selected_events">
  372.                                 <xsl:with-param name="Total" select="count($selected_events)"/>
  373.                             </xsl:apply-templates>
  374.                     </xsl:otherwise>
  375.                 </xsl:choose>
  376.  
  377.             </xsl:otherwise>
  378.     </xsl:choose>
  379.    </xsl:template>
  380.  
  381. </xsl:stylesheet>
  382.